# -*- coding:utf-8 -*-
"""
@Time : 2020-12-15 11:23
@Author: langengel
@Des: 数据库配置
"""

import os

# -----------------------数据库配置-----------------------------------
# 生产环境请使用系统环境变量，以免泄露个人数据
MYSQL_USER = os.getenv('MYSQL_USER', 'root')
MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD', '123456')
MYSQL_HOST = os.getenv('MYSQL_HOST', 'localhost')
MYSQL_PORT = os.getenv('MYSQL_PORT', 3306)
MYSQL_DB = os.getenv('MYSQL_DB', 'saas')


DB_ORM_CONFIG = {
    "connections": {
        "default": {
            'engine': 'tortoise.backends.mysql',
            "credentials": {
                'host': MYSQL_HOST,
                'port': int(MYSQL_PORT),
                'user': MYSQL_USER,
                'password': MYSQL_PASSWORD,
                'database': MYSQL_DB,
            }

        },
        # "db2connect": {
        #     'host': 'localhost',
        #     'port': 3306,
        #     'user': 'root',
        #     'password': '123456',
        #     'database': 'service',
        # },
    },
    "apps": {
        "default": {"models": ["models.saas"], "connection": "default"},
        # "db2": {"models": [], "connection": "db2connect"},
    },
    'use_tz': False,
    'timezone': 'Asia/Shanghai'
}
